package com.xdd.dao.config.db;

/**
 * Created by bjlixiaozu on 2018/3/20.
 */
public class AbstractResourceConfig
{
    private String dsName;
    private String driverClassName;
    private String url;
    private String user;
    private String password;
    private int initialSize;
    private int minIdle;
    private int maxActive;
    private String validationQuery;
    private Boolean poolPreparedStatements;
    private int maxOpenPreparedStatements;
    private long timeBetweenLogStatsMillis;
    private Boolean logSlowSql;
    private Long slowSqlMillis;
    private Boolean mergeSql;
    private Boolean dataSourceLogEnabled;
    private Boolean connectionLogEnabled;
    private Boolean connectionLogErrorEnabled;
    private Boolean statementLogEnabled;
    private Boolean statementLogErrorEnabled;
    private Boolean resultSetLogEnabled;
    private Boolean resultSetLogErrorEnabled;
    private boolean useUtf8mb4Connection;

    public String getDsName()
    {
        return dsName;
    }

    public AbstractResourceConfig setDsName(String dsName)
    {
        this.dsName = dsName;
        return this;
    }

    public String getDriverClassName()
    {
        return driverClassName;
    }

    public AbstractResourceConfig setDriverClassName(String driverClassName)
    {
        this.driverClassName = driverClassName;
        return this;
    }

    public String getUrl()
    {
        return url;
    }

    public AbstractResourceConfig setUrl(String url)
    {
        this.url = url;
        return this;
    }

    public String getUser()
    {
        return user;
    }

    public AbstractResourceConfig setUser(String user)
    {
        this.user = user;
        return this;
    }

    public String getPassword()
    {
        return password;
    }

    public AbstractResourceConfig setPassword(String password)
    {
        this.password = password;
        return this;
    }

    public int getInitialSize()
    {
        return initialSize;
    }

    public AbstractResourceConfig setInitialSize(int initialSize)
    {
        this.initialSize = initialSize;
        return this;
    }

    public int getMinIdle()
    {
        return minIdle;
    }

    public AbstractResourceConfig setMinIdle(int minIdle)
    {
        this.minIdle = minIdle;
        return this;
    }

    public int getMaxActive()
    {
        return maxActive;
    }

    public AbstractResourceConfig setMaxActive(int maxActive)
    {
        this.maxActive = maxActive;
        return this;
    }

    public String getValidationQuery()
    {
        return validationQuery;
    }

    public AbstractResourceConfig setValidationQuery(String validationQuery)
    {
        this.validationQuery = validationQuery;
        return this;
    }

    public Boolean getPoolPreparedStatements()
    {
        return poolPreparedStatements;
    }

    public AbstractResourceConfig setPoolPreparedStatements(Boolean poolPreparedStatements)
    {
        this.poolPreparedStatements = poolPreparedStatements;
        return this;
    }

    public int getMaxOpenPreparedStatements()
    {
        return maxOpenPreparedStatements;
    }

    public AbstractResourceConfig setMaxOpenPreparedStatements(int maxOpenPreparedStatements)
    {
        this.maxOpenPreparedStatements = maxOpenPreparedStatements;
        return this;
    }

    public long getTimeBetweenLogStatsMillis()
    {
        return timeBetweenLogStatsMillis;
    }

    public AbstractResourceConfig setTimeBetweenLogStatsMillis(long timeBetweenLogStatsMillis)
    {
        this.timeBetweenLogStatsMillis = timeBetweenLogStatsMillis;
        return this;
    }

    public Boolean getLogSlowSql()
    {
        return logSlowSql;
    }

    public AbstractResourceConfig setLogSlowSql(Boolean logSlowSql)
    {
        this.logSlowSql = logSlowSql;
        return this;
    }

    public Long getSlowSqlMillis()
    {
        return slowSqlMillis;
    }

    public AbstractResourceConfig setSlowSqlMillis(Long slowSqlMillis)
    {
        this.slowSqlMillis = slowSqlMillis;
        return this;
    }

    public Boolean getMergeSql()
    {
        return mergeSql;
    }

    public AbstractResourceConfig setMergeSql(Boolean mergeSql)
    {
        this.mergeSql = mergeSql;
        return this;
    }

    public Boolean getDataSourceLogEnabled()
    {
        return dataSourceLogEnabled;
    }

    public AbstractResourceConfig setDataSourceLogEnabled(Boolean dataSourceLogEnabled)
    {
        this.dataSourceLogEnabled = dataSourceLogEnabled;
        return this;
    }

    public Boolean getConnectionLogEnabled()
    {
        return connectionLogEnabled;
    }

    public AbstractResourceConfig setConnectionLogEnabled(Boolean connectionLogEnabled)
    {
        this.connectionLogEnabled = connectionLogEnabled;
        return this;
    }

    public Boolean getConnectionLogErrorEnabled()
    {
        return connectionLogErrorEnabled;
    }

    public AbstractResourceConfig setConnectionLogErrorEnabled(Boolean connectionLogErrorEnabled)
    {
        this.connectionLogErrorEnabled = connectionLogErrorEnabled;
        return this;
    }

    public Boolean getStatementLogEnabled()
    {
        return statementLogEnabled;
    }

    public AbstractResourceConfig setStatementLogEnabled(Boolean statementLogEnabled)
    {
        this.statementLogEnabled = statementLogEnabled;
        return this;
    }

    public Boolean getStatementLogErrorEnabled()
    {
        return statementLogErrorEnabled;
    }

    public AbstractResourceConfig setStatementLogErrorEnabled(Boolean statementLogErrorEnabled)
    {
        this.statementLogErrorEnabled = statementLogErrorEnabled;
        return this;
    }

    public Boolean getResultSetLogEnabled()
    {
        return resultSetLogEnabled;
    }

    public AbstractResourceConfig setResultSetLogEnabled(Boolean resultSetLogEnabled)
    {
        this.resultSetLogEnabled = resultSetLogEnabled;
        return this;
    }

    public Boolean getResultSetLogErrorEnabled()
    {
        return resultSetLogErrorEnabled;
    }

    public AbstractResourceConfig setResultSetLogErrorEnabled(Boolean resultSetLogErrorEnabled)
    {
        this.resultSetLogErrorEnabled = resultSetLogErrorEnabled;
        return this;
    }

    public boolean getUseUtf8mb4Connection()
    {
        return useUtf8mb4Connection;
    }

    public AbstractResourceConfig setUseUtf8mb4Connection(boolean useUtf8mb4Connection)
    {
        this.useUtf8mb4Connection = useUtf8mb4Connection;
        return this;
    }

    @Override
    public String toString()
    {
        final StringBuilder sb = new StringBuilder("{");
        sb.append("\"dsName\":\"")
                .append(dsName).append('\"');
        sb.append(",\"driverClassName\":\"")
                .append(driverClassName).append('\"');
        sb.append(",\"url\":\"")
                .append(url).append('\"');
        sb.append(",\"user\":\"")
                .append(user).append('\"');
        sb.append(",\"password\":\"")
                .append(password).append('\"');
        sb.append(",\"initialSize\":")
                .append(initialSize);
        sb.append(",\"minIdle\":")
                .append(minIdle);
        sb.append(",\"maxActive\":")
                .append(maxActive);
        sb.append(",\"validationQuery\":\"")
                .append(validationQuery).append('\"');
        sb.append(",\"poolPreparedStatements\":")
                .append(poolPreparedStatements);
        sb.append(",\"maxOpenPreparedStatements\":")
                .append(maxOpenPreparedStatements);
        sb.append(",\"timeBetweenLogStatsMillis\":")
                .append(timeBetweenLogStatsMillis);
        sb.append(",\"logSlowSql\":")
                .append(logSlowSql);
        sb.append(",\"slowSqlMillis\":")
                .append(slowSqlMillis);
        sb.append(",\"mergeSql\":")
                .append(mergeSql);
        sb.append(",\"dataSourceLogEnabled\":")
                .append(dataSourceLogEnabled);
        sb.append(",\"connectionLogEnabled\":")
                .append(connectionLogEnabled);
        sb.append(",\"connectionLogErrorEnabled\":")
                .append(connectionLogErrorEnabled);
        sb.append(",\"statementLogEnabled\":")
                .append(statementLogEnabled);
        sb.append(",\"statementLogErrorEnabled\":")
                .append(statementLogErrorEnabled);
        sb.append(",\"resultSetLogEnabled\":")
                .append(resultSetLogEnabled);
        sb.append(",\"resultSetLogErrorEnabled\":")
                .append(resultSetLogErrorEnabled);
        sb.append(",\"useUtf8mb4Connection\":")
                .append(useUtf8mb4Connection);
        sb.append('}');
        return sb.toString();
    }
}
